package com.kjs.common.exception;

import com.kjs.common.tools.LoggerUtil;
import lombok.Getter;
import org.slf4j.Logger;

/**
 * 平台基础一次
 */
@Getter
public class KjsAppException extends RuntimeException {
    protected Logger logger;
    protected String action;
    protected Integer userId;
    protected Integer err;
    protected String reason;

    public KjsAppException(String action) {
        super();
        this.action = action;
    }

    public KjsAppException(Logger logger, String action, Integer userId, Integer err, String reason) {
        super();
        this.logger = logger;
        this.action = action;
        this.userId = userId;
        this.err = err;
        this.reason = reason;
    }

    public void error(Logger log) {
        LoggerUtil.error(logger == null ? log : logger, action, userId, err.toString(), reason);
    }
}
